package com.example.springdemo;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

@RestController
@RequestMapping("/wms/web")
public class ShuZiHuaController {

    private static final Logger log = LoggerFactory.getLogger(ShuZiHuaController.class);

    /**
     * 承载具[数字化物料接口]
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "getBearerDeviceCodeList")
    public Object getBearerDeviceCodeList() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getBearerDeviceCodeList.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "dic_bearer_list_shuzihua")
    public Object dic_bearer_list_shuzihua() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("dic_bearer_list_shuzihua.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "/images/upload")
    public Object images_upload() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("images_upload.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


}





